﻿using SrBBSPro.Util;
using SrBBSPro.BaseClasses;
using NPoco;
using System;

namespace SrBBSPro.Entities
{
    /// <summary>
    /// 帖子实体
    /// </summary>
    [TableName("Posts")]
    [PrimaryKey("Id")]
    public class Post : BaseEntity<long>
    {
        /// <summary>
        /// 帖子主题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 帖子内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 所属分类
        /// </summary>
        public string SkillKind { get; set; }

        [Ignore]
        public string SkillKindName
        {
            get
            {
                switch (SkillKind)
                {
                    case "OSSkill":
                        return "操作系统";
                    case "ServerSkill":
                        return "服务器";
                    case "DBOSkill":
                    case "DBHSkill":
                    case "DBLink":;
                        return "数据库";
                    case "PhoneSkill":
                        return "移动端";
                    case "HostLang":
                    case "OpenLang":
                        return "后端开发语言";
                    case "PageSkill":
                        return "前端开发语言";
                    case "ScriptLang":
                        return "脚本语言";
                    case "ReportSkill":
                        return "报表(帐票)";
                    case "OtherLang":
                        return "其他开发语言";
                    default:
                        return "";
                }
            }
        }
        
        /// <summary>
        /// 技能名称
        /// </summary>
        public string SkillName { get; set; }
        
        /// <summary>
        /// 悬赏积分
        /// </summary>
        public int Reward { get; set; }
        /// <summary>
        /// 帖子状态
        /// </summary>
        public PostStatus PostStatus { get; set; }
        /// <summary>
        /// 是否为精贴
        /// </summary>
        public bool IsBoutique { get; set; }
        /// <summary>
        /// 是否置顶
        /// </summary>
        public bool IsTop { get; set; }
        /// <summary>
        /// 排序值
        /// </summary>
        public int Sort { get; set; }
        /// <summary>
        /// 发表时间
        /// </summary>
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 最后编辑时间
        /// </summary>
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 点击量
        /// </summary>
        public int Hits { get; set; }
        /// <summary>
        /// 帖子被收藏数
        /// </summary>
        public int Collection { get; set; }
        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsShow { get; set; }

        /// <summary>
        /// 获取文字描述的时间
        /// </summary>
        [Ignore]
        public string TimeAgo
        {
            get
            {
                return DateHelper.TimeAgoStr(DateTime.Now, CreateTime);
            }
        }
        /// <summary>
        /// 获取评论数
        /// </summary>
        public int CommentCount {get; set;}


        public string UserId { get; set; }
        
        [Reference(ReferenceType.OneToOne, ColumnName = "UserId", ReferenceMemberName = "Id")]
        public User User { get; set; }

    }
}
